<template>
        <el-dialog title="新增" v-model="editFormVisible" :close-on-click-modal="false">
            <el-form ref="form" :model="form" :rules="rules" label-width="110px">
                <el-form-item label="回款批次"  prop="FIncomeType">
                    <sy-select v-model="form.FIncomeType"  valueKey="FName"
                               optionData="server/system/SetType.ashx?cmd=GetOptions&FType=3">
                    </sy-select>
                </el-form-item>
                <el-form-item label="付款金额(万元)" prop="FPayAmount">
                    <el-input v-model="form.FPayAmount"></el-input>
                    <!--<el-input-number  :controls="false" :min="0" v-model="form.FPayAmount" style="width: 100%"></el-input-number>-->
                </el-form-item>
                <el-form-item label="付款时间">
                    <el-date-picker type="date" placeholder="选择日期" v-model="form.FPayDate"  style="width: 100%"></el-date-picker>
                </el-form-item>
                <el-form-item label="开票金额(万元)" prop="FInvoiceAmount">
                    <el-input v-model="form.FInvoiceAmount"></el-input>
                    <!--<el-input-number  :controls="false" :min="0" v-model="form.FInvoiceAmount" style="width: 100%"></el-input-number>-->
                </el-form-item>
                <el-form-item label="开票时间">
                    <el-date-picker type="date" placeholder="选择日期" v-model="form.FVoiceDate"  style="width: 100%"></el-date-picker>
                </el-form-item>
                <el-form-item label="经办人">
                    <sy-select v-model="form.FUserName" valueKey="FName"
                               optionData="server/system/User.ashx?cmd=GetUserOptions">
                    </sy-select>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input type="textarea" v-model="form.FNote"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="editFormVisible = false">取 消</el-button>
                <el-button v-if="authEdit"  type="primary" @click="save" :loading="loading">保存</el-button>
            </div>
      </el-dialog>
</template>

<script>
    import util from '../../common/util'
    import mixin from '../../common/mixin'
    export default {
        mixins: [mixin],
        data() {
            return {
                authEdit:false,
                form: {},
                rules: {
                    FIncomeType: [{required: true,message: '请输入收入类型', trigger: 'blur'}],
                    FInvoiceAmount:[ { validator: this.isFloat, trigger: 'change' }],
                    FPayAmount:[ { validator: this.isFloat, trigger: 'change' }]
                },
                loading:false,
                editFormVisible:false
            }
        },
        methods: {
            switchLoading(flag){
                this.loading = flag;
            },
            _openEdit(record,authEdit) {
                this.authEdit = authEdit
                this.editFormVisible = true;
                this.form = Object.assign({},record);
            },
            _openAdd(record) {
                this.authEdit = true
                this.editFormVisible = true;
                var from = {FID:0,FPayDate:null,FVoiceDate:null,FUserName:global.user.FName};
                this.form = Object.assign(from,record);
            },
            save:function () {
                util.saveForm("server/customer/ContractIncome.ashx?cmd=Save",this.$refs.form,this.form,this.switchLoading,result=> {
                    util.msgSuc("保存成功")
                    this.editFormVisible = false
                    this.$emit("onSaveSuc",this.form)
                })
            }
        }
    }
</script>
